package com.ruoyi.eam.api.factory;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.eam.api.RemoteEamService;
import com.ruoyi.eam.api.domain.EamLocation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * ema服务降级处理
 */
@Component
public class RemoteEamFallbackFactory implements FallbackFactory<RemoteEamService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteEamFallbackFactory.class);


    @Override
    public RemoteEamService create(Throwable throwable) {
        log.error("eam服务调用失败:{}", throwable.getMessage());

        return new RemoteEamService() {

            @Override
            public R<EamLocation> getEamLocationById(Long id) {

                return R.fail("获取eam位置信息失败:" + throwable.getMessage());
            }
        };
    }
}
